<?php
namespace app\api\controller;
use app\api\controller\WeixinPay;
use app\api\controller\Wxpay;
use app\api\controller\Wpay;
use app\api\controller\Base;
use think\Controller;
use think\Db;
use think\Request;
use think\db\Where;
class Payfee extends Base
{
    public function pay(){
        // include 'WeixinPay.php';
        // $request=new Request();
        $code=input("post.code");
        $appid='wx7cff958a038c1630'; //小程序appid
        $openid=input("post.openid");
        $mch_id='1607938869'; //微信支付商户支付号
        $key='ququpinggou1688hsshop9com1688xzc'; //Api密钥
        $out_trade_no = $mch_id. time();
        $total_fee = input("post.order_price");
        if (empty($total_fee)) { //押金
          $body = "充值押金";
          $total_fee = floatval(99*100);
        } else {
           $body = "充值余额";
           $total_fee = floatval($total_fee*100);
         }
        $weixinpay = new WeixinPay($appid,$openid,$mch_id,$key,$out_trade_no,$body,$total_fee);
        $return=$weixinpay->pay();
        // $weixinpay = new Wxpay();
        // $return=$weixinpay->wechartAddOrder($appid,$openid,$mch_id,$key,$out_trade_no,$body,$total_fee);
        // $weixinpay = new Wpay($appid,$openid,$mch_id,$key,$out_trade_no,$body,$total_fee);
        // $return=$weixinpay->pay();
        echo json_encode($return);
    }
    //修改订单状态
    public function uporder(){
        
     }
}